import  os,xlrd,arcpy,arcgisscripting,sys

excelPath = 'C:\Users\lenovo\Desktop\\africa\data\origin\\Murdock_EA_2011_vkZ.xls'
excelFile=xlrd.open_workbook(excelPath)
sheet=excelFile.sheet_by_index(0)

# print sheet.name,sheet.nrows,sheet.ncols

gp = arcgisscripting.create()
gp.OverwriteOutput = 1

outputShpPath = sys.argv[1]
outWorkspace = os.path.split(outputShpPath)[0]
shpName = os.path.split(outputShpPath)[-1]

spat_ref = "4326"
gp.CreateFeatureClass_management(outWorkspace, shpName, "POLYGON", "", "", "", spat_ref)
gp.addfield(outputShpPath, "NAME", "text", "", "", "100")
cur = gp.InsertCursor(outputShpPath)
newRow = cur.newRow()
for i in range(1,sheet.nrows):
    row = sheet.row_values(i)
    newRow.NAME = row[1]
    pnt = gp.CreateObject("point")
    array = gp.CreateObject("array")
    arcpy.AddMessage('row:{0}'.format(i))
    for j in range(9,sheet.ncols,2):
        if not row[j] or not row[j+1]:
            arcpy.AddMessage('{0} is not num'.format(row[j-1]))
            break
        pnt.X,pnt.Y =float(str(row[j]).split(')')[0]),float(str(row[j+1]).split(')')[0])
        # arcpy.AddMessage('{0},{1}'.format( pnt.X,pnt.Y))
        array.add(pnt)
    newRow.Shape = array
    cur.InsertRow(newRow)
del cur, newRow

